#######################################################################
#Name of code file: clickbait_analysis.R

#Data In: clickbait_data.csv

#Data Out: Figures 5 & A3 
######################################################################

#Load packages
library(dplyr)
library(ggplot2)
library(readr)
library(ggthemes)

#Set Working Directory
setwd("../diresta_grossman_siegel_replication/")

#Read in Data
data<-read_csv("data/clickbait_data.csv")

#Figure 5

#Plot Monthly Proportion of Clickbait 

data %>% 
  ggplot() + 
  aes(x = month, y = prop, color=source) + 
  geom_point(alpha = 0.5) + 
  geom_smooth(span=1, alpha=.25, se=FALSE)+
  labs(y = "Monthly Prop. of Syria Posts", x = "Date")+
  theme_minimal(base_size=18)+
  #scale_colour_grey(start=.2, end=.7)
ggsave("plots/Figure5.pdf", width = 15, height = 8)

#Figure A3

#Aggregate Clickbait Across Sources

all_clickbait<-data %>% 
  group_by(source) %>%
  summarise(prop = mean(prop))

#Plot 

ggplot(data=all_clickbait, aes(x=source, y=prop, fill=source)) +
  geom_bar(stat="identity", position=position_dodge())+
  scale_fill_brewer(palette="Blues")+
  theme_minimal(base_size=20)+
  theme(legend.position="none")
ggsave("plots/FigureA3.pdf", width = 11, height = 8)





